home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / Gui4Cli / Tools / Read.gc < prev    next >
Encoding:
Gui4CLI script  |  1980-01-03  |  3.8 KB  |  181 lines

  1. G4C
  2.  
  3. ; A File Reader.
  4.  
  5. ; You MUST set variable *FILENAME to the name of the file you want
  6. ; displayed, before you call this gui - otherwise you'll get a requester.
  7.  
  8.  
  9. WinBig 0 11 0 -13 "Loading..."    ; you may want to change the position
  10. WinType 11110001
  11. Varpath 'read.pop/read.srch'      ; use private vars & 2 other guis vars
  12.  
  13. ;------> On Loading, we open the gui's window..
  14. ;     and load the file stated in the variable "*FILENAME"
  15. ;        This has been set by an other GUI, since we get called from there.
  16.  
  17. xOnLoad
  18. setscreen read.gc $*DEF.SCREEN
  19. dglv_path = ''
  20. setgad read.gc 2 hide      ; hide the 2nd listview
  21. guiopen read.gc
  22. ifexists variable *FILENAME
  23. andifexists file $*FILENAME
  24.    gosub read.gc filechange
  25. else
  26.    gosub read.gc getfile
  27. endif
  28.  
  29. ;-------> Upon closing, we quit so as not to use-up memory
  30.  
  31. xOnClose
  32. guiquit read.gc
  33.  
  34. ;------> on RMB we open our pop-up command window
  35.  
  36. xOnRMB 
  37. guiopen Read.pop
  38.  
  39. ;------> on quitting we also quit our other 2 guis
  40.  
  41. xonquit
  42. guiquit  read.srch
  43. guiquit  read.pop
  44.  
  45. ;------> Routine to load & show file
  46.  
  47. xRoutine filechange             ; routine to load & show file
  48. guiscreen read.gc front
  49. SetWinTitle read.gc "Loading...."
  50. lvuse read.gc 1            ; choose our display listview
  51. LVChange $*FILENAME
  52. SetWinTitle read.gc '$*FILENAME                                '
  53.  
  54. ;------------> the listview. - Use 'L' for scrolling the list up/down
  55.  
  56. xListview 0 0 0 0 "" dglv_line "" 20 TXT
  57. GadID  1
  58. GadFont topaz.font 8 000     ; CHANGE THE FONT HERE!
  59.  
  60. ;------------> open a requester and get a file
  61.  
  62. xroutine getfile
  63. setvar dglv_getfile ""
  64. ReqFile -1 -1 250 200 "Choose file" LOAD dglv_getfile $dglv_path
  65. if $dglv_getfile != ""
  66.    *FILENAME = $dglv_getfile
  67.    gosub read.gc filechange
  68. endif
  69.  
  70.  
  71. ;######################################################################
  72. ; commands pop-up gui
  73.  
  74. NEWFILE read.pop
  75.  
  76.  
  77. WinBig 0 0 80 75 ""
  78. WinType 00001000
  79. winonmouse 30 7 
  80. varpath read.gc        ; use our main gui's vars
  81.  
  82. xOnRMB 
  83. guiclose Read.pop
  84.  
  85. xOnInactive
  86. guiclose Read.pop
  87.  
  88. xOnFail
  89. ezreq "Error during operation" OK ""
  90.  
  91. ;---------------> the Buttons
  92.  
  93. xbutton 0 0 0 15 Open
  94. guiclose Read.pop
  95. extract *FILENAME PATH dglv_path
  96. gosub read.gc getfile
  97.  
  98. xbutton 0 15 0 15 Edit
  99. guiclose Read.pop
  100. ifexists gui cedbar.gc            ; This is for CEd (long story..)
  101.    guiscreen cedbar.gc front
  102.    sendrexx rexx_ced 'open new'
  103.    sendrexx rexx_ced 'open $*FILENAME'
  104.    sendrexx rexx_ced 'expand view'
  105. elseifexists variable *DEF.EDITOR
  106.    run '$*DEF.EDITOR $*FILENAME'    ; if called from a file manager
  107. else
  108.    run 'c:ed $*FILENAME'        ; use ed if nothing defined
  109. endif
  110.  
  111.  
  112. xbutton 0 30 0 15 Search
  113. guiclose read.pop
  114. guiopen  read.srch
  115.  
  116.  
  117. xbutton 0 45 0 15 'Delete'
  118. action delete $*FILENAME req
  119.  
  120. xbutton 0 60 0 15 Quit
  121. guiclose read.pop
  122. guiquit  read.gc
  123.  
  124.  
  125. ;######################################################################
  126. ; search for string gui
  127.  
  128. NEWFILE read.srch
  129.  
  130. winbig -1 -1 300 32 'Enter Search string :'
  131. wintype 11110001
  132. varpath ''
  133.  
  134. xonopen        ; reset variables on opening
  135. mode = CI
  136. flag = 0
  137.  
  138.  
  139. xTextIn  0 0 0 15 '' str '' 128
  140. gosub read.srch search
  141.  
  142.  
  143. xCycler  0 17 150 14 '' mode    ; choose case sensitive/insen..
  144. cstr 'Ignore case' CI
  145. cstr 'Same case'   CS
  146.  
  147.  
  148. xButton 150 17 100 14 'Top'    ; go to top of lv
  149. flag = 0            
  150. lvgo #0
  151. update read.gc 1 0
  152. setwintitle read.srch 'Enter search string :'
  153.  
  154.  
  155. xButton  250 17 50 14 >>
  156. gosub read.srch search
  157.  
  158.  
  159. xroutine search
  160. if $str = ''        ; no string entered 
  161.    stop
  162. endif
  163. lvuse read.gc 1        ; use the reader's listview
  164. if $flag = 0        ; flag=0 means this is the first time
  165.    flag = 1
  166.    lvsearch $str $mode first    ; Keywords such as mode (CI or CS), do
  167.                 ; not get translated, but in lvsearch
  168.                 ; it's an exception, so we can say $mode
  169. else
  170.    lvsearch $str $mode next
  171. endif
  172. if $$lv.line > ''        ; update to line found
  173.    update read.gc 1 $$lv.line
  174.    setwintitle read.srch 'Line $$lv.line'
  175. else
  176.    lvgo #0            ; or else go top again
  177.    flag = 0
  178.    setwintitle read.srch 'Search Finished'
  179. endif
  180.  
  181.